package com.toubutu.audio.auth.controller;

import com.toubutu.anno.LoginRequired;
import com.toubutu.audio.auth.service.SendVerifyCodeService;
import com.toubutu.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 戒躁
 * @version 1.0
 * @date 2023年10月21日 2:12
 */
@RestController
@Api(tags = "验证码接口")
@RequestMapping("/code")
public class VerifyCodeController {
    @Resource
    private SendVerifyCodeService codeService;
    @ApiOperation("发送邮箱验证码")
    @PostMapping("/email")
    public Result<Void> sendEmailCode(@RequestParam String email){
        codeService.sendEmailCode(email);
        return Result.ok();
    }

    @GetMapping("/submit")
    @ApiOperation("获取提交码")
    @LoginRequired
    public Result<String> getSubmitCode(){
        return Result.ok(codeService.generateSubmitCode());
    }
}
